import service from '@/utils/request.js'

// 登录
export function Login(data){
    return service({
        url:'/api/user/login',
        method:'post',
        data,
    })
}

// 注册
export function Register(data){
    return service({
        url:'/api/user/register',
        method:'post',
        data,
    })
}

// 查询用户信息
export function GetUserInfo(id){
    return service({
        url:'/api/user/' + id,
        method:'get'
    })
}

// 虚拟传参,获取用户信息
export function UserInfo(data){
    return service({
        url:'/api/user/' + data,
        method:'post',
    })
}

// 模糊查询
export function SearchFilm(name){
    return service({
        url:'/api/film/name/' + name,
        method:'get', 
    })
}

// 走马灯
export function ListAllPoster(){
    return service({
        url:'/api/poster',
        method:'get',
    })
}

// 查询电影列表
export function nowplaying(type, region){
    return service({
        url:'/api/film/' + type + "/" + region,
        method:'get',
    })
}

// 查询热门电影信息
export function hotfilm(limit){
    return service({
        url:'/api/film/hot/' + limit,
        method:'get',
    })
}

// 查询电影详情
export function getFilmDetailById(id){
    return service({
        url:"/api/film/" + id,
        method:'get',
    })
}

// 获取电影评论
export function getFilmEvaluate(fid){
    return service({
        url: '/api/fe/' + fid,
        method: 'get',
    })
}

// 评价电影
export function sendEvaluate(fid, uid, comment, star){
    return service({
        url: '/api/fe',
        method: 'post',
        data:{
            fid,
            uid,
            comment,
            star,
        }
    })
}

// 查询电影排片信息
export function getArrangement(fid){
    return service({
        url: '/api/arrangement/film/' + fid,
        method: 'get'
    })
}

// 查询电影某场次信息
export function getArrangementById(id){
    return service({
        url: '/api/arrangement/' + id,
        method: 'get'
    })
}

// 查询已经被占的座位号
export function getSeats(id){
    return service({
        url: '/api/arrangement/getseats/' + id,
        method: 'get'
    })
}

// 加入购物车
export function subOrder(uid, aid, seats, phone, status, price){
    return service({
        url: '/api/cart',
        method: 'post',
        data:{
            uid,
            aid,
            seats,
            phone,
            status,
            price
        }
    })
}

// 获取活动
export function getActivity(){
    return service({
        url: '/api/activity',
        method: 'get'
    })
}

// 报名
export function signUpActivity(aid, uid){
    return service({
        url: '/api/registration',
        method: 'post',
        data:{
            aid,
            uid
        }
    })
}

// 查询员工列表
export function getWorkerList(){
    return service({
        url: '/api/worker',
        method: 'get',
    })
}

// 查询影院留言
export function getLeavingMsg(){
    return service({
        url: '/api/lm',
        method: 'get'
    })
}

// 获取客服评价
export function getWorkerEvaMsg(wid, uid){
    return service({
        url:'/api/we/' + wid,
        method:'get',
    })
}

// 评价客服
export function evaluateWorker(wid, uid, content, type){
    return service({
        url: 'api/we',
        method: 'post',
        data: {
            wid,
            uid,
            content,
            type
        }
    })
}

// 影院留言
export function LeavingMsg(uid, content){
    return service({
        url: 'api/lm',
        method: 'post',
        data: {
            uid,
            content,
        }
    })
}

// 获取购物车列表
export function getShoppingcar(uid){
    return service({
        url:'/api/cart/' + uid,
        method:'get',
    })
}

// 删除购物车
export function deleteCartById(id){
    return service({
        url: '/api/cart',
        method: 'delete',
        data:id
    })
}

// 保存订单
export function saveOrder(uid, phone, aid, seats, price, status){
    return service({
        url: '/api/order',
        method: 'post',
        data: {
            uid,
            phone,
            aid,
            seats,
            price,
            status
        }
    })
}

// 查询订单列表
export function getMyOrder(uid){
    return service({
        url: '/api/order/user/' + uid,
        method: 'get',
    })
}

// 支付订单
export function payment(id){
    return service({
        url: '/api/order/pay/' + id,
        method:'get',
    })
}

// 更新用户信息
export function userUpdate(id,username,password,nickname,email,birthday,gender,info,avatar){
    return service({
        url:'/api/user',
        method: 'put',
        data: {
            id,
            username,
            password,
            nickname,
            email,
            birthday,
            gender,
            info,
            avatar,
        }
    })
}
